package com.igogogo.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.codec.digest.DigestUtils;

public class WordUtils {

	/**
	 * MD5
	 * 
	 * @param word
	 *            需要加密的字符串
	 * 
	 */
	public static String md5(String word) {
		String md5Hex = DigestUtils.md5Hex(word);
		return md5Hex;
	}

	public static String queryMeUrl(String me) {
		Pattern p = Pattern.compile("e=(.*)&traceId");
		Matcher m = p.matcher(me);
		while (m.find()) {
			return m.group(1);
		}
		return null;
	}

	/**
	 * @param 通过ME获取连接部分
	 *            https://uland.taobao.com/coupon/edetail 该URL中 ?e=后面的内容
	 *            &traceId 之前的内容
	 */
	public static String meargs(String me) {
		Pattern p = Pattern.compile("e=(.*)&traceId");
		Matcher m = p.matcher(me);
		while (m.find()) {
			return m.group(1);
		}
		return null;
	}

}
